package com.alipay.demo.trade.utils;



import com.zbl.zblproject.core.dto.OrderItemDTO;
import com.zbl.zblproject.core.entity.OrderItem;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;


/**
 * 数据生成工具
 */
public class DataGeneratorUtil {


    /**
     * 数据生成方法
     * @param
     * @return
     */
    public static List<OrderItemDTO> generatorDTO(List<OrderItem> orderItems) {
        int i=1;
        List<OrderItemDTO> orderItemDTOS = new ArrayList<>();
        for (OrderItem orderItem:orderItems) {
            OrderItemDTO orderItemDTO = new OrderItemDTO();
            orderItemDTO.setGoodsNum(String.valueOf(orderItem.getGoodsNum()));
            double b=0;
            double d=0;
            if (orderItem.getShopPrice()!=null){
                b = orderItem.getShopPrice().doubleValue();
            }
            if (orderItem.getDiscount()!=null){
                d =orderItem.getDiscount().doubleValue();
            }
            d=b*d;
            if (orderItem.getGoodsNum()!=0){
                d = d*Double.valueOf(orderItem.getGoodsNum());
            }
            orderItemDTO.setTotalMoney(String.valueOf(d));
            orderItemDTO.setSuppliersName(orderItem.getSupplierName());
            orderItemDTO.setShopPrice(String.valueOf(orderItem.getShopPrice()));
            orderItemDTO.setOrderSn(orderItem.getOrderSn());
            orderItemDTO.setGoodsName(orderItem.getGoodsName());
            orderItemDTO.setBrandName(orderItem.getBrandName());
            orderItemDTO.setGoodsDesc(orderItem.getGoodsDesc());
            orderItemDTO.setCount(i);
            i++;
            orderItemDTOS.add(orderItemDTO);
        }
        return orderItemDTOS;
    }
}
